package com.weilele.leisure.time.ui.holder

import android.os.Bundle
import android.view.Gravity
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.DrawableRes
import com.weilele.leisure.time.R
import com.weilele.leisure.time.databinding.HolderSettingClickItemBinding
import com.weilele.mvvm.adapter.MvvmHolder
import com.weilele.mvvm.utils.activity.onClick
import com.weilele.mvvm.utils.activity.setIcon


class SettingClickItemHolder :
    MvvmHolder<SettingClickItemHolder.Bean, HolderSettingClickItemBinding> {
    constructor(binding: HolderSettingClickItemBinding) : super(binding)
    constructor(itemView: View) : super(itemView)

    data class Bean(
        var text: String,
        val onclick: Function1<View, Unit>?,
        @DrawableRes var endDrawable: Int = R.drawable.icon_click_next,
    )

    override fun bindData(data: Bean) {
        mBinding.text.text = data.text
        if (data.onclick == null) {
            mBinding.text.setIcon(drawable = null)
        } else {
            mBinding.text.setIcon(data.endDrawable, gravity = Gravity.END)
            mBinding.text.onClick(null,data.onclick)
        }
    }
}